home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / program / tpcx113.zip / PCX.ASM < prev    next >
Assembly Source File  |  1996-11-14  |  3KB  |  140 lines

  1. ;
  2. ; Tiny PCX Viewer v1.13
  3. ;
  4. ; PCX Viewer in only 136 bytes!
  5. ; Displays 320x200x256 PCX files only.
  6. ;
  7. ; Syntax: PCX filename.pcx
  8. ;
  9. ; Note: Error checking is very sparse (what can you expect in 149 bytes ;-)
  10. ; ~~~~
  11. ;
  12. ; Copyright (C) 1996, Adarsh Kini and J. C. Kiran.
  13. ;    Shrinking by Terje Mathisen (The Shrink Guy decreased 13 Bytes eh !)
  14. ;
  15. ;   e-mail: adk@poboxes.com
  16. ;           jck@poboxes.com
  17. ;        Terje.Mathisen@hda.hydro.com
  18. ;
  19. ;   BBS:  'KIRAN J C' at INFOMART BBS: +91 (80) 5598401/02, 28.8k
  20. ;         'ADARSH KINI' at INFOMART BBS
  21. ;
  22. ; This program was written as a answer to the challenge put up
  23. ;  by someone who said that his viewer was the smallest (184 bytes)
  24. ;
  25. ; Can anybody answer us ? We are listening.   ;-)
  26. ;
  27. ; This code is released into the public domain. Use as you please.
  28. ;
  29. ; This is the result of our first attempt at displaying PCX files and
  30. ; it took us only 3 hours!
  31. ;
  32. ; Compile with TASM after enabling multiple passes to filter out the
  33. ; extra NOPs. Link with Tlink
  34. ;
  35. ; Coming next: Tiny BMP!   (We think so)
  36. ;
  37. ; If you can get a smaller viewer, we would be happy to take a look.
  38. ;
  39. ; With special thanks to Devesh 'Devilish' Agarwal, SysOp, INFOMART BBS,
  40. ;  for opening up the System Programmers forum where the best brains
  41. ;  hang out. Special thanks to the Shrinker Mathisen for shrinking 13 bytes !
  42. ;
  43. ; Also thanks to Srivatsa K. Srinivasan (vatsa@poboxes.com) for letting
  44. ;  us know about the challenge.
  45. ;
  46. ;--------------------------------------------------------------------------
  47.  
  48. _TEXT    SEGMENT    'CODE'
  49.     ASSUME cs:_TEXT,ds:_TEXT,es:_TEXT
  50.     org    80h
  51. cmdlen    label    byte
  52.     org    81h
  53. cmdline    label    byte
  54.     org    100h
  55. start:
  56.     align    1
  57.     mov     si,offset cmdlen           ; BEGIN The shrinker's code
  58.     xor     bh,bh
  59.     mov    bl,[si]
  60.     mov     [bx + cmdline],0
  61. skipspace:
  62.     inc    si
  63.     mov    byte ptr [si+bx],bh
  64.     cmp    byte ptr [si],20h
  65.     je    skipspace            ; END The Shrinker's Code
  66. oknow:
  67.     xchg    si,dx
  68.     mov     ax,3D00h        ; Open the file
  69.     int    21h
  70.     jc    exit
  71.     xchg    ax,bx            ; 1 Byte only!
  72.  
  73.     mov    ax,4200h        ; Skip first 128 bytes
  74.     xor    cx,cx
  75.     mov    dx,128
  76.     int    21h
  77.     jc    exit
  78.  
  79.     mov    ah,3Fh            ; Read 64000 bytes
  80.     mov    cx,64000
  81.     mov    dx,offset loadpos
  82.     int    21h
  83.     jc    exit
  84.  
  85.     mov    ah,3Eh            ; Close the file
  86.     int    21h
  87.  
  88.     xor    di,di
  89.     mov     si,offset loadpos
  90.     mov    ax, 0A000h
  91.         mov     es, ax
  92.  
  93.     mov    ax,0013h        ; Set 320x200x256
  94.     int     10h
  95.     xor    ch,ch
  96.     xor    bx,bx
  97.     xor    ah,ah
  98.  
  99. pcxloop:
  100.     lodsb                ; BEGIN The Shrinker's Code
  101.     cmp    al,11000000b
  102.     jb    writedata
  103.     and    al,00111111b
  104.     mov    cl,al
  105.     lodsb
  106.     rep
  107. writedata:
  108.     stosb
  109.     cmp    di,64000        ; Test for end of data
  110.     jb    pcxloop            ; END The Shrinker's Code
  111. exitdisp:                ; Fix the palette
  112.     mov    cx,3*256
  113.     push    ds
  114.     pop    es
  115.     inc    si            ; Skip the 12 decimal id byte
  116.     mov    dx,si
  117.     mov    di,si
  118. paletteloop:
  119.     lodsb
  120.     shr    al,1
  121.     shr    al,1
  122.     stosb
  123.     loop    paletteloop
  124.                     ; Now set the palette
  125.     mov    ax,1012h
  126.     xor    bx,bx
  127.     mov    cx,256
  128.     int    10h
  129.  
  130.         xor     ax,ax                   ; Wait for keypress
  131.     int    16h
  132.  
  133. exit:
  134.         mov     ax,3                    ; Set mode 3 (80x25) text
  135.     int    10h
  136.         int     20h                     
  137. loadpos label byte
  138. _TEXT     ends
  139.     end    start
  140.